FeedDeletePlugin = Class.extend({
	init: function()	{
		this.name = "FeedDeletePlugin";
	},
	
	onDeleteFeedClicked: function(eventData)	{
		var id = eventData.id;
		var event = eventData.event;
		this.onAjax('feed', 'delete-feed', {id: id}, 'POST', {
			'onSuccess': function(ret)	{
				alert('Xoá thành công!');
				$(event.target).parent().parent().remove();
			}
		});
	},
	
	onHtmlUpdated: function(eventData)	{
		var props = SingletonFactory.getInstance(Application).getSystemProperties();
		var login = props.get('user.login');
		if (login == 0)
			return;
		var id = props.get('user.id');
		$('.extension-point[extensionName="FeedItem"]').each(function() {
			if ($(this).find('[flag="FeedDelete"]').length > 0)
				return;
			var from = $(this).attr('fromID');
			var to = $(this).attr('toID');
			if (id != from && id != to)
				return;
			var feedID = $(this).attr('feedID');
			$(this).append(tmpl('FeedDeleteTmpl', {id: feedID}));
		});
	}
}).implement(PluginInterface).implement(AjaxInterface);